package com.spzx.product.api.fallback;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.ProductDetailsFeignClient;
import com.spzx.product.api.domain.ProductDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * @ClassName ProductDetailsFeignClientFallbackFactory
 * @Author 波
 * @Date 2024/8/5 20:45
 */
@Slf4j
public class ProductDetailsFeignClientFallbackFactory implements FallbackFactory<ProductDetailsFeignClient> {
    @Override
    public ProductDetailsFeignClient create(Throwable cause) {
        log.error("商品服务调用失败"+cause.getMessage());
        return new ProductDetailsFeignClient() {
            @Override
            public R<ProductDetails> details(Long pid, String source) {
                return R.fail("获取商品详情失败:" + cause.getMessage());
            }
        };
    }
}
